home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / pvm34b3.zip / pvm34b3 / pvm3 / tracer / trccompat.c < prev    next >
C/C++ Source or Header  |  1997-07-22  |  18KB  |  1,117 lines

  1.  
  2. static char rcsid[] = 
  3.     "$Id: trccompat.c,v 4.3 1997/05/01 15:10:01 pvmsrc Exp $";
  4.  
  5. /*
  6.  *         Tracer version 1.0:  A Trace File Generator for PVM
  7.  *           Oak Ridge National Laboratory, Oak Ridge TN.
  8.  *           Authors:  James Arthur Kohl and G. A. Geist
  9.  *                   (C) 1994 All Rights Reserved
  10.  *
  11.  *                              NOTICE
  12.  *
  13.  * Permission to use, copy, modify, and distribute this software and
  14.  * its documentation for any purpose and without fee is hereby granted
  15.  * provided that the above copyright notice appear in all copies and
  16.  * that both the copyright notice and this permission notice appear
  17.  * in supporting documentation.
  18.  *
  19.  * Neither the Institution, Oak Ridge National Laboratory, nor the
  20.  * Authors make any representations about the suitability of this
  21.  * software for any purpose.  This software is provided ``as is''
  22.  * without express or implied warranty.
  23.  *
  24.  * Tracer was funded by the U.S. Department of Energy.
  25.  */
  26.  
  27.  
  28. /* Tracer Headers */
  29.  
  30. #include "trclib.h"
  31.  
  32. #include "trccompat.h"
  33.  
  34.  
  35. /* Old Trace File Generation Routines - For Compatibility */
  36.  
  37.  
  38. /* Trace Lookup Trie Init Routines */
  39.  
  40. void
  41. trc_init_old_events()
  42. {
  43.     int i;
  44.  
  45.     TRC_OLD_EVENT_TRIE = trc_create_triestack();
  46.  
  47.     for ( i=TRC_OLD_TEV_FIRST ; i < TRC_OLD_TRACE_MAX ; i++ )
  48.     {
  49.         if ( strcmp( TRC_OLD_TEV_TRACE_NAMES[i], "" ) )
  50.         {
  51.             trc_add_to_trie( TRC_OLD_EVENT_TRIE,
  52.                 TRC_OLD_TEV_TRACE_NAMES[i],
  53.                 (void *) ( ( i - TRC_OLD_TEV_FIRST ) + 1 ) );
  54.         }
  55.  
  56.         TRC_OLD_TEV_TRACE[i] = 0;
  57.     }
  58. }
  59.  
  60.  
  61. int
  62. trc_process_old_trace_event( ID, name )
  63. TRC_ID ID;
  64. char *name;
  65. {
  66.     long tmp;
  67.  
  68.     int tusec;
  69.     int tsec;
  70.     int flag;
  71.     int eid;
  72.     int tid;
  73.  
  74.     if ( !trc_find_event_str( ID, "{" ) )
  75.         return( TRC_FALSE );
  76.  
  77.     /* } to match above */
  78.  
  79.     flag = fscanf( ID->trace_in, "%d, %d, %d", &tsec, &tusec, &tid );
  80.  
  81.     if ( flag != 3 )
  82.     {
  83.         printf( "Incomplete Trace Record\n" );
  84.  
  85.         return( TRC_FALSE );
  86.     }
  87.  
  88.     if ( tmp = (long) trc_lookup_trie( TRC_OLD_EVENT_TRIE, name ) )
  89.     {
  90.         eid = (int) tmp;
  91.  
  92.         eid = ( eid - 1 ) + TRC_OLD_TEV_FIRST;
  93.  
  94.         if ( ID->handle_old_event )
  95.             (ID->handle_old_event)( ID, eid, tsec, tusec, tid );
  96.  
  97.         else
  98.             trc_find_event_end( ID );
  99.  
  100.         return( TRC_TRUE );
  101.     }
  102.  
  103.     else
  104.     {
  105.         printf( "Error: Event \"%s\" Not Found\n", name );
  106.  
  107.         trc_find_event_end( ID );
  108.  
  109.         return( TRC_FALSE );
  110.     }
  111. }
  112.  
  113.  
  114. int
  115. trc_store_old_trace_event( ID, tsec, tusec, tid, eid )
  116. TRC_ID ID;
  117. int tsec;
  118. int tusec;
  119. int tid;
  120. int eid;
  121. {
  122.     static int *tids = (int *) NULL;
  123.     static int ntids = 0;
  124.  
  125.     TRC_TEVTASK TT;
  126.  
  127.     char where[4096];
  128.     char name[4096];
  129.     char msg[255];
  130.  
  131.     int msgtag;
  132.     int nbytes;
  133.     int ignore;
  134.     int count;
  135.     int flags;
  136.     int addr;
  137.     int ecnt;
  138.     int host;
  139.     int type;
  140.     int ptid;
  141.     int dtid;
  142.     int stid;
  143.     int omit;
  144.     int len;
  145.     int buf;
  146.     int num;
  147.     int cc;
  148.     int i;
  149.  
  150.     /* Set Leftover Event Omit Flag */
  151.  
  152.     TT = trc_get_tevtask_tid( ID, tid );
  153.  
  154.     omit = ( ID->trace_out == NULL
  155.         || ( TT != NULL && TRC_TASK_OMIT( TT ) ) )
  156.             ? TRC_TRUE : TRC_FALSE;
  157.  
  158.     /* Initialize Event Counter */
  159.  
  160.     ecnt = 0;
  161.  
  162.     if ( !omit )
  163.     {
  164.         /* Output Trace Event Descriptor (if necessary) */
  165.  
  166.         if ( !( TRC_OLD_TEV_TRACE[ eid ] ) )
  167.         {
  168.             fprintf( ID->trace_out, "\n" );
  169.  
  170.             if ( ID->event_dump_hdr )
  171.                 (ID->event_dump_hdr)( ID, tid );
  172.  
  173.             fprintf( ID->trace_out, "#%d: %s\n", eid + 1,
  174.                 TRC_OLD_TRACE_DESCRIPTORS[ eid ] );
  175.  
  176.             (TRC_OLD_TEV_TRACE[ eid ])++;
  177.         }
  178.  
  179.         /* Update Trace Time */
  180.  
  181.         trc_update_trace_time( tsec, tusec );
  182.  
  183.         /* Output Trace Event Header */
  184.  
  185.         if ( ID->event_dump_hdr )
  186.             (ID->event_dump_hdr)( ID, tid );
  187.  
  188.         fprintf( ID->trace_out, "\"%s\" { %d, %d, %d",
  189.             TRC_OLD_TEV_TRACE_NAMES[ eid ], tsec, tusec, tid );  /* } */
  190.     }
  191.  
  192.     /* Convert Trace to Output File */
  193.  
  194.     switch ( eid )
  195.     {
  196.         case TRC_OLD_TEV_NEWTASK:
  197.         {
  198.             if ( omit )
  199.                 break;
  200.  
  201.             pvm_upkint( &ptid, 1, 1 );
  202.             pvm_upkint( &flags, 1, 1 );
  203.             pvm_upkstr( name );
  204.  
  205.             if ( !strcmp( name, "" ) )
  206.                 strcpy( name, "-" );
  207.  
  208.             host = pvm_tidtohost( tid );
  209.  
  210.             fprintf( ID->trace_out, ", %d, %d, %d",
  211.                 ptid, host, flags );
  212.  
  213.             trc_dump_trace_str( ID, name, TRC_TRUE );
  214.  
  215.             ignore = 0;
  216.  
  217.             if ( !(ID->group_tasks) && TRC_GROUPTASK( name ) )
  218.                 ignore++;
  219.  
  220.             if ( TT == NULL )
  221.             {
  222.                 if ( !ignore )
  223.                 {
  224.                     sprintf( msg, "Task TID=0x%x Connected to %s",
  225.                         tid, TRC_NAME );
  226.  
  227.                     trc_status_msg( ID, msg );
  228.                 }
  229.  
  230.                 TT = trc_create_tevtask();
  231.  
  232.                 TT->tid = tid;
  233.  
  234.                 TT->outstatus = TRC_TASK_NOOUT;
  235.  
  236.                 TT->next = ID->tevtask_list;
  237.  
  238.                 ID->tevtask_list = TT;
  239.             }
  240.  
  241.             if ( !ignore )
  242.                 TT->tevstatus = TRC_TASK_ALIVE;
  243.             
  244.             else
  245.                 TT->tevstatus = TRC_TASK_IGNORE;
  246.  
  247.             break;
  248.         }
  249.  
  250.         case TRC_OLD_TEV_SPNTASK:
  251.         {
  252.             if ( omit )
  253.                 break;
  254.  
  255.             trc_dump_old_pvm_event_fmt( ID, eid );
  256.  
  257.             if ( TT == NULL )
  258.             {
  259.                 sprintf( msg, "Task TID=0x%x Connected to %s",
  260.                     tid, TRC_NAME );
  261.  
  262.                 trc_status_msg( ID, msg );
  263.  
  264.                 TT = trc_create_tevtask();
  265.  
  266.                 TT->tid = tid;
  267.  
  268.                 TT->tevstatus = TRC_TASK_ALIVE;
  269.                 TT->outstatus = TRC_TASK_NOOUT;
  270.  
  271.                 TT->next = ID->tevtask_list;
  272.  
  273.                 ID->tevtask_list = TT;
  274.             }
  275.  
  276.             break;
  277.         }
  278.  
  279.         case TRC_OLD_TEV_ENDTASK:
  280.         {
  281.             if ( !omit )
  282.                 trc_dump_old_pvm_event_fmt( ID, eid );
  283.  
  284.             if ( TT != NULL )
  285.             {
  286.                 if ( TT->tevstatus == TRC_TASK_ALIVE )
  287.                 {
  288.                     TT->tevstatus = TRC_TASK_DEAD;
  289.  
  290.                     trc_check_for_dead_host( ID, TT );
  291.  
  292.                     if ( !trc_tevtasks_alive( ID ) )
  293.                         trc_end_trace( ID );
  294.                 }
  295.  
  296.                 else
  297.                     TT->tevstatus = TRC_TASK_DEAD;
  298.             }
  299.  
  300.             else if ( !omit )
  301.             {
  302.                 printf( "\nWarning: ENDTASK Unknown Task TID=0x%x.\n\n",
  303.                     tid );
  304.             }
  305.  
  306.             break;
  307.         }
  308.  
  309.         case TRC_OLD_TEV_ADDHOSTS0:
  310.         {
  311.             if ( omit )
  312.                 break;
  313.  
  314.             pvm_upkint( &num, 1, 1 );
  315.  
  316.             fprintf( ID->trace_out, ", %d, [%d][100] { ", num, num );
  317.  
  318.             for ( i=0 ; i < num ; i++ )
  319.             {
  320.                 pvm_upkstr( name );
  321.  
  322.                 if ( i != num - 1 )
  323.                     fprintf( ID->trace_out, "\"%s\", ", name );
  324.                 
  325.                 else
  326.                     fprintf( ID->trace_out, "\"%s\" }", name );
  327.             }
  328.  
  329.             break;
  330.         }
  331.  
  332.         case TRC_OLD_TEV_ADDHOSTS1:
  333.         {
  334.             if ( omit )
  335.                 break;
  336.  
  337.             pvm_upkint( &cc, 1, 1 );
  338.  
  339.             fprintf( ID->trace_out, ", %d", cc );
  340.  
  341.             break;
  342.         }
  343.  
  344.         case TRC_OLD_TEV_SPAWN0:
  345.         {
  346.             if ( omit )
  347.                 break;
  348.  
  349.             pvm_upkstr( name );
  350.             pvm_upkint( &flags, 1, 1 );
  351.             pvm_upkstr( where );
  352.             pvm_upkint( &count, 1, 1 );
  353.  
  354.             trc_dump_trace_str( ID, name, TRC_TRUE );
  355.  
  356.             fprintf( ID->trace_out, ", %d", flags );
  357.  
  358.             trc_dump_trace_str( ID, where, TRC_TRUE );
  359.  
  360.             fprintf( ID->trace_out, ", %d", count );
  361.  
  362.             break;
  363.         }
  364.  
  365.         case TRC_OLD_TEV_SPAWN1:
  366.         {
  367.             if ( omit )
  368.                 break;
  369.  
  370.             pvm_upkint( &num, 1, 1 );
  371.  
  372.             fprintf( ID->trace_out, ", %d, [%d] {", num, num );
  373.  
  374.             if ( num > 0 )
  375.             {
  376.                 if ( num > ntids )
  377.                 {
  378.                     ntids = num * 2;
  379.  
  380.                     if ( tids != NULL )
  381.                         free( tids );
  382.  
  383.                     tids = (int *) malloc( (unsigned) ntids
  384.                         * sizeof(int) );
  385.                     trc_memcheck( tids, "Spawn TIDs" );
  386.                 }
  387.  
  388.                 pvm_upkint( tids, num, 1 );
  389.  
  390.                 for ( i=0 ; i < num ; i++ )
  391.                 {
  392.                     if ( i )
  393.                         fprintf( ID->trace_out, ", %d", tids[i] );
  394.                     
  395.                     else
  396.                         fprintf( ID->trace_out, " %d", tids[i] );
  397.                 }
  398.             }
  399.  
  400.             fprintf( ID->trace_out, " }" );
  401.  
  402.             break;
  403.         }
  404.  
  405.         case TRC_OLD_TEV_SEND0:
  406.         {
  407.             if ( omit )
  408.                 break;
  409.  
  410.             pvm_upkint( &dtid, 1, 1 );
  411.             pvm_upkint( &msgtag, 1, 1 );
  412.  
  413.             fprintf( ID->trace_out, ", %d, %d", dtid, msgtag );
  414.  
  415.             break;
  416.         }
  417.  
  418.         case TRC_OLD_TEV_MCAST0:
  419.         {
  420.             if ( omit )
  421.                 break;
  422.  
  423.             pvm_upkint( &num, 1, 1 );
  424.             pvm_upkint( &msgtag, 1, 1 );
  425.  
  426.             fprintf( ID->trace_out, ", %d, %d, [%d] {",
  427.                 num, msgtag, num );
  428.  
  429.             if ( num > 0 )
  430.             {
  431.                 if ( num > ntids )
  432.                 {
  433.                     ntids = num * 2;
  434.  
  435.                     if ( tids != NULL )
  436.                         free( tids );
  437.  
  438.                     tids = (int *) malloc( (unsigned) ntids
  439.                         * sizeof(int) );
  440.                     trc_memcheck( tids, "Mcast TIDs" );
  441.                 }
  442.  
  443.                 pvm_upkint( tids, num, 1 );
  444.  
  445.                 for ( i=0 ; i < num ; i++ )
  446.                 {
  447.                     if ( i )
  448.                         fprintf( ID->trace_out, ", %d", tids[i] );
  449.                 
  450.                     else
  451.                         fprintf( ID->trace_out, " %d", tids[i] );
  452.                 }
  453.             }
  454.  
  455.             fprintf( ID->trace_out, " }" );
  456.  
  457.             break;
  458.         }
  459.  
  460.         case TRC_OLD_TEV_PSEND0:
  461.         {
  462.             if ( omit )
  463.                 break;
  464.  
  465.             pvm_upkint( &dtid, 1, 1 );
  466.             pvm_upkint( &msgtag, 1, 1 );
  467.             pvm_upkint( &addr, 1, 1 );
  468.             pvm_upkint( &len, 1, 1 );
  469.             pvm_upkint( &type, 1, 1 );
  470.  
  471.             fprintf( ID->trace_out, ", %d, %d, %d, %d, %d",
  472.                 dtid, msgtag, addr, len, type );
  473.  
  474.             break;
  475.         }
  476.  
  477.         case TRC_OLD_TEV_RECV1:
  478.         case TRC_OLD_TEV_TRECV1:
  479.         {
  480.             if ( omit )
  481.                 break;
  482.  
  483.             pvm_upkint( &buf, 1, 1 );
  484.             pvm_upkint( &nbytes, 1, 1 );
  485.  
  486.             if ( nbytes >= 0 )
  487.             {
  488.                 pvm_upkint( &msgtag, 1, 1 );
  489.                 pvm_upkint( &stid, 1, 1 );
  490.             }
  491.  
  492.             else
  493.                 msgtag = stid = -1;
  494.  
  495.             fprintf( ID->trace_out, ", %d, %d, %d, %d",
  496.                 buf, nbytes, msgtag, stid );
  497.  
  498.             break;
  499.         }
  500.  
  501.         case TRC_OLD_TEV_PRECV1:
  502.         {
  503.             if ( omit )
  504.                 break;
  505.  
  506.             pvm_upkint( &buf, 1, 1 );
  507.  
  508.             fprintf( ID->trace_out, ", %d, 0, 0, 0", buf );
  509.  
  510.             break;
  511.         }
  512.  
  513.         case TRC_OLD_TEV_NRECV1:
  514.         {
  515.             if ( omit )
  516.                 break;
  517.  
  518.             pvm_upkint( &buf, 1, 1 );
  519.  
  520.             if ( buf > 0 )
  521.             {
  522.                 pvm_upkint( &nbytes, 1, 1 );
  523.  
  524.                 if ( nbytes >= 0 )
  525.                 {
  526.                     pvm_upkint( &msgtag, 1, 1 );
  527.                     pvm_upkint( &stid, 1, 1 );
  528.                 }
  529.  
  530.                 else
  531.                     msgtag = stid = -1;
  532.             }
  533.  
  534.             else
  535.                 nbytes = msgtag = stid = -1;
  536.  
  537.             fprintf( ID->trace_out, ", %d, %d, %d, %d",
  538.                 buf, nbytes, msgtag, stid );
  539.  
  540.             break;
  541.         }
  542.  
  543.         default:
  544.         {
  545.             if ( !omit )
  546.                 trc_dump_old_pvm_event_fmt( ID, eid );
  547.         }
  548.     }
  549.  
  550.     if ( !omit )
  551.     {
  552.         /* Finish Off Trace Event ({) */
  553.  
  554.         fprintf( ID->trace_out, " };;\n" );
  555.  
  556.         ecnt++;
  557.     }
  558.  
  559.     return( ecnt );
  560. }
  561.  
  562.  
  563. void
  564. trc_dump_old_pvm_event_fmt( ID, eid )
  565. TRC_ID ID;
  566. int eid;
  567. {
  568.     char buf[4096];
  569.  
  570.     char *fmt;
  571.  
  572.     int keeplist[10];
  573.  
  574.     int vecflag;
  575.     int veclen;
  576.     int index;
  577.     int nkeep;
  578.     int keep;
  579.     int ival;
  580.  
  581.     fmt = trc_old_tev_formats[ eid ].fmt;
  582.  
  583.     if ( fmt != NULL )
  584.     {
  585.         nkeep = 0;
  586.  
  587.         while ( *fmt )
  588.         {
  589.             if ( *fmt == '%' )
  590.             {
  591.                 fmt++;
  592.  
  593.                 if ( *fmt == '*' )
  594.                 {
  595.                     keep = TRC_TRUE;
  596.  
  597.                     fmt++;
  598.                 }
  599.  
  600.                 else
  601.                     keep = TRC_FALSE;
  602.  
  603.                 if ( *fmt == '$' )
  604.                 {
  605.                     fmt++;
  606.  
  607.                     index = *fmt - '0';
  608.  
  609.                     fmt++;
  610.  
  611.                     veclen = ( index >= 0 && index < nkeep )
  612.                         ? keeplist[index] : 0;
  613.  
  614.                     vecflag = TRC_TRUE;
  615.                 }
  616.  
  617.                 else
  618.                 {
  619.                     veclen = 1;
  620.  
  621.                     vecflag = TRC_FALSE;
  622.                 }
  623.  
  624.                 while ( veclen > 0 )
  625.                 {
  626.                     veclen--;
  627.  
  628.                     switch ( *fmt )
  629.                     {
  630.                         case 'R':
  631.                         case 'd':
  632.                         case 'r':
  633.                         case 'x':
  634.                         {
  635.                             pvm_upkint( &ival, 1, 1 );
  636.         
  637.                             fprintf( ID->trace_out, ", %d", ival );
  638.         
  639.                             break;
  640.                         }
  641.         
  642.                         case 'S':
  643.                         {
  644.                             pvm_upkstr( buf );
  645.         
  646.                             trc_dump_trace_str( ID, buf, TRC_TRUE );
  647.         
  648.                             break;
  649.                         }
  650.         
  651.                         default:
  652.                             break;
  653.                     }
  654.                 }
  655.     
  656.                 if ( *fmt )
  657.                     fmt++;
  658.  
  659.                 if ( keep )
  660.                 {
  661.                     keeplist[nkeep] = ival < 0 ? 0 : ival;
  662.  
  663.                     nkeep++;
  664.                 }
  665.             }
  666.             
  667.             else
  668.                 fmt++;
  669.         }
  670.     }
  671. }
  672.  
  673.  
  674. void
  675. trc_write_old_output_event( ID, tid, str )
  676. TRC_ID ID;
  677. int tid;
  678. char *str;
  679. {
  680.     if ( !( TRC_OLD_TEV_TRACE[ TRC_OLD_TRACE_OUTPUT ] ) )
  681.     {
  682.         fprintf( ID->trace_out, "\n" );
  683.  
  684.         if ( ID->event_dump_hdr )
  685.             (ID->event_dump_hdr)( ID, tid );
  686.  
  687.         fprintf( ID->trace_out, "#%d: %s\n",
  688.             TRC_OLD_TRACE_OUTPUT + 1,
  689.             TRC_OLD_TRACE_DESCRIPTORS[ TRC_OLD_TRACE_OUTPUT ] );
  690.  
  691.         (TRC_OLD_TEV_TRACE[ TRC_OLD_TRACE_OUTPUT ])++;
  692.     }
  693.  
  694.     if ( ID->event_dump_hdr )
  695.         (ID->event_dump_hdr)( ID, tid );
  696.  
  697.     fprintf( ID->trace_out, "\"%s\" { %d, %d, %d",
  698.         TRC_OLD_TEV_TRACE_NAMES[ TRC_OLD_TRACE_OUTPUT ],
  699.         TRC_TRACE_TIME.tv_sec, TRC_TRACE_TIME.tv_usec, tid );
  700.  
  701.     trc_dump_trace_str( ID, str, TRC_TRUE );
  702.  
  703.     fprintf( ID->trace_out, " };;\n" );
  704. }
  705.  
  706.  
  707. void
  708. trc_write_old_host_add_event( ID, H )
  709. TRC_ID ID;
  710. TRC_HOST H;
  711. {
  712.     if ( !( TRC_OLD_TEV_TRACE[ TRC_OLD_TRACE_HOST_ADD ] ) )
  713.     {
  714.         fprintf( ID->trace_out, "\n" );
  715.  
  716.         if ( ID->event_dump_hdr )
  717.             (ID->event_dump_hdr)( ID, H->pvmd_tid );
  718.  
  719.         fprintf( ID->trace_out, "#%d: %s\n",
  720.             TRC_OLD_TRACE_HOST_ADD + 1,
  721.             TRC_OLD_TRACE_DESCRIPTORS[ TRC_OLD_TRACE_HOST_ADD ] );
  722.  
  723.         (TRC_OLD_TEV_TRACE[ TRC_OLD_TRACE_HOST_ADD ])++;
  724.     }
  725.  
  726.     if ( ID->event_dump_hdr )
  727.         (ID->event_dump_hdr)( ID, H->pvmd_tid );
  728.  
  729.     fprintf( ID->trace_out, "\"%s\" { %d, %d, %d",
  730.         TRC_OLD_TEV_TRACE_NAMES[ TRC_OLD_TRACE_HOST_ADD ],
  731.         TRC_TRACE_TIME.tv_sec, TRC_TRACE_TIME.tv_usec, H->pvmd_tid );
  732.  
  733.     trc_dump_trace_str( ID, H->refname, TRC_TRUE );
  734.  
  735.     trc_dump_trace_str( ID, H->alias, TRC_TRUE );
  736.  
  737.     trc_dump_trace_str( ID, H->arch, TRC_TRUE );
  738.  
  739.     fprintf( ID->trace_out, ", %d };;\n", H->speed );
  740. }
  741.  
  742.  
  743. void
  744. trc_write_old_host_del_event( ID, H, tid )
  745. TRC_ID ID;
  746. TRC_HOST H;
  747. int tid;
  748. {
  749.     char tmp[1024];
  750.  
  751.     if ( !( TRC_OLD_TEV_TRACE[ TRC_OLD_TRACE_HOST_DEL ] ) )
  752.     {
  753.         fprintf( ID->trace_out, "\n" );
  754.  
  755.         if ( ID->event_dump_hdr )
  756.             (ID->event_dump_hdr)( ID, tid );
  757.  
  758.         fprintf( ID->trace_out, "#%d: %s\n",
  759.             TRC_OLD_TRACE_HOST_DEL + 1,
  760.             TRC_OLD_TRACE_DESCRIPTORS[ TRC_OLD_TRACE_HOST_DEL ] );
  761.  
  762.         (TRC_OLD_TEV_TRACE[ TRC_OLD_TRACE_HOST_DEL ])++;
  763.     }
  764.  
  765.     if ( ID->event_dump_hdr )
  766.         (ID->event_dump_hdr)( ID, tid );
  767.  
  768.     fprintf( ID->trace_out, "\"%s\" { %d, %d, %d",
  769.         TRC_OLD_TEV_TRACE_NAMES[ TRC_OLD_TRACE_HOST_DEL ],
  770.         TRC_TRACE_TIME.tv_sec, TRC_TRACE_TIME.tv_usec, tid );
  771.  
  772.     if ( strcmp( H->refname, "" ) )
  773.     {
  774.         sscanf( H->refname, "%s", tmp );
  775.  
  776.         trc_dump_trace_str( ID, tmp, TRC_TRUE );
  777.     }
  778.  
  779.     else
  780.         trc_dump_trace_str( ID, H->refname, TRC_TRUE );
  781.  
  782.     fprintf( ID->trace_out, " };;\n" );
  783. }
  784.  
  785.  
  786. void
  787. trc_write_old_host_sync_event( ID, H )
  788. TRC_ID ID;
  789. TRC_HOST H;
  790. {
  791.     if ( !( TRC_OLD_TEV_TRACE[ TRC_OLD_TRACE_HOST_SYNC ] ) )
  792.     {
  793.         fprintf( ID->trace_out, "\n" );
  794.  
  795.         if ( ID->event_dump_hdr )
  796.             (ID->event_dump_hdr)( ID, H->pvmd_tid );
  797.  
  798.         fprintf( ID->trace_out, "#%d: %s\n",
  799.             TRC_OLD_TRACE_HOST_SYNC + 1,
  800.             TRC_OLD_TRACE_DESCRIPTORS[ TRC_OLD_TRACE_HOST_SYNC ] );
  801.  
  802.         (TRC_OLD_TEV_TRACE[ TRC_OLD_TRACE_HOST_SYNC ])++;
  803.     }
  804.  
  805.     if ( ID->event_dump_hdr )
  806.         (ID->event_dump_hdr)( ID, H->pvmd_tid );
  807.  
  808.     fprintf( ID->trace_out, "\"%s\" { %d, %d, %d, %d, %d };;\n",
  809.         TRC_OLD_TEV_TRACE_NAMES[ TRC_OLD_TRACE_HOST_SYNC ],
  810.         TRC_TRACE_TIME.tv_sec, TRC_TRACE_TIME.tv_usec, H->pvmd_tid,
  811.         H->delta.tv_sec, H->delta.tv_usec );
  812.  
  813.     H->last_time.tv_sec = TRC_TRACE_TIME.tv_sec;
  814.     H->last_time.tv_usec = TRC_TRACE_TIME.tv_usec;
  815. }
  816.  
  817.  
  818. char *
  819. trc_old_pvm_event_string( ID, eid )
  820. TRC_ID ID;
  821. int eid;
  822. {
  823.     char result[4096];
  824.     char tmp[2048];
  825.     char buf[1024];
  826.  
  827.     char *fmt;
  828.     char *str;
  829.  
  830.     int keeplist[10];
  831.  
  832.     int vecflag;
  833.     int veclen;
  834.     int index;
  835.     int nkeep;
  836.     int keep;
  837.     int ival;
  838.     int sep;
  839.  
  840.     fmt = trc_old_tev_formats[ eid ].fmt;
  841.  
  842.     if ( fmt != NULL )
  843.     {
  844.         nkeep = 0;
  845.  
  846.         if ( *fmt != '=' )
  847.             sprintf( result, "%s", trc_old_tev_formats[ eid ].name );
  848.  
  849.         else
  850.             sprintf( result, "%s() ", trc_old_tev_formats[ eid ].name );
  851.     
  852.         while ( *fmt )
  853.         {
  854.             if ( *fmt == '%' )
  855.             {
  856.                 fmt++;
  857.  
  858.                 if ( *fmt == '*' )
  859.                 {
  860.                     keep = TRC_TRUE;
  861.  
  862.                     fmt++;
  863.                 }
  864.  
  865.                 else
  866.                     keep = TRC_FALSE;
  867.  
  868.                 if ( *fmt == '$' )
  869.                 {
  870.                     fmt++;
  871.  
  872.                     index = *fmt - '0';
  873.  
  874.                     fmt++;
  875.  
  876.                     veclen = ( index >= 0 && index < nkeep )
  877.                         ? keeplist[index] : 0;
  878.  
  879.                     vecflag = TRC_TRUE;
  880.  
  881.                     sep = TRC_FALSE;
  882.                 }
  883.  
  884.                 else
  885.                 {
  886.                     veclen = 1;
  887.  
  888.                     vecflag = TRC_FALSE;
  889.                 }
  890.  
  891.                 while ( veclen > 0 )
  892.                 {
  893.                     veclen--;
  894.  
  895.                     if ( vecflag )
  896.                     {
  897.                         if ( sep )
  898.                             trc_append_str( result, " ", 4096 );
  899.  
  900.                         sep = TRC_TRUE;
  901.                     }
  902.  
  903.                     switch ( *fmt )
  904.                     {
  905.                         case 'd':
  906.                         {
  907.                             fscanf( ID->trace_in, ", %d", &ival );
  908.         
  909.                             sprintf( tmp, " %d", ival );
  910.         
  911.                             trc_append_str( result, tmp, 4096 );
  912.     
  913.                             break;
  914.                         }
  915.         
  916.                         /* decimal result code */
  917.                         case 'R':
  918.                         {
  919.                             fscanf( ID->trace_in, ", %d", &ival );
  920.         
  921.                             sprintf( tmp, " %d", ival );
  922.     
  923.                             trc_append_str( result, tmp, 4096 );
  924.     
  925.                             if ( ival < 0 )
  926.                             {
  927.                                 if ( ival <= 0
  928.                                     && ival > -trc_old_pvm_nerr )
  929.                                 {
  930.                                     sprintf( tmp, " (%s)",
  931.                                         trc_old_pvm_errlist[ -ival ] );
  932.                                 }
  933.                                 
  934.                                 else
  935.                                 {
  936.                                     sprintf( tmp, " %d (Unknown Error)",
  937.                                         ival );
  938.                                 }
  939.     
  940.                                 trc_append_str( result, tmp, 4096 );
  941.                             }
  942.         
  943.                             break;
  944.                         }
  945.         
  946.                         /* hex result code / decimal if negative */
  947.                         case 'r':
  948.                         {
  949.                             fscanf( ID->trace_in, ", %d", &ival );
  950.         
  951.                             if ( ival < 0 )
  952.                             {
  953.                                 if ( ival <= 0
  954.                                     && ival > -trc_old_pvm_nerr )
  955.                                 {
  956.                                     sprintf( tmp, " %d (%s)", ival,
  957.                                         trc_old_pvm_errlist[ -ival ] );
  958.                                 }
  959.     
  960.                                 else
  961.                                 {
  962.                                     sprintf( tmp, " %d (Unknown Error)",
  963.                                         ival );
  964.                                 }
  965.                             }
  966.                             
  967.                             else
  968.                                 sprintf( tmp, " 0x%x", ival );
  969.         
  970.                             trc_append_str( result, tmp, 4096 );
  971.     
  972.                             break;
  973.                         }
  974.         
  975.                         case 'x':
  976.                         {
  977.                             fscanf( ID->trace_in, ", %d", &ival );
  978.         
  979.                             sprintf( tmp, " 0x%x", ival );
  980.         
  981.                             trc_append_str( result, tmp, 4096 );
  982.         
  983.                             break;
  984.                         }
  985.         
  986.                         case 'S':
  987.                         {
  988.                             trc_read_old_trace_str( ID,
  989.                                 buf, 1024, TRC_TRUE );
  990.         
  991.                             sprintf( tmp, " \"%s\"", buf );
  992.         
  993.                             trc_append_str( result, tmp, 4096 );
  994.         
  995.                             break;
  996.                         }
  997.         
  998.                         default:
  999.                         {
  1000.                             sprintf( tmp, "%%%c", *fmt );
  1001.         
  1002.                             trc_append_str( result, tmp, 4096 );
  1003.     
  1004.                             break;
  1005.                         }
  1006.                     }
  1007.                 }
  1008.     
  1009.                 if ( *fmt )
  1010.                     fmt++;
  1011.                 
  1012.                 if ( keep )
  1013.                 {
  1014.                     keeplist[nkeep] = ival < 0 ? 0 : ival;
  1015.  
  1016.                     nkeep++;
  1017.                 }
  1018.             }
  1019.             
  1020.             else
  1021.             {
  1022.                 sprintf( tmp, "%c", *fmt++ );
  1023.  
  1024.                 trc_append_str( result, tmp, 4096 );
  1025.             }
  1026.         }
  1027.     }
  1028.  
  1029.     else
  1030.         sprintf( result, "%s()", trc_old_tev_formats[ eid ].name );
  1031.  
  1032.     trc_find_event_end( ID );
  1033.  
  1034.     str = trc_copy_str( result );
  1035.  
  1036.     return( str );
  1037. }
  1038.  
  1039.  
  1040. int
  1041. trc_read_old_trace_str( ID, str, size, end_flag )
  1042. TRC_ID ID;
  1043. char *str;
  1044. int size;
  1045. int end_flag;
  1046. {
  1047.     char c;
  1048.  
  1049.     int i;
  1050.  
  1051.     *str = '\0';
  1052.  
  1053.     if ( !trc_find_event_str( ID, "\"" ) )
  1054.         return( TRC_FALSE );
  1055.  
  1056.     i = 0;
  1057.  
  1058.     while ( (c = getc( ID->trace_in )) != (char) EOF && c != '"'
  1059.         && i < size - 1 )
  1060.     {
  1061.         str[i++] = c;
  1062.     }
  1063.  
  1064.     str[i] = '\0';
  1065.  
  1066.     TRC_CKEOF( c, "EOF Reading Trace String\n", return( TRC_FALSE ) );
  1067.  
  1068.     if ( c != '"' )
  1069.     {
  1070.         if ( !trc_find_event_str( ID, "\"" ) )
  1071.             return( TRC_FALSE );
  1072.     }
  1073.  
  1074.     if ( end_flag )
  1075.     {
  1076.         /* Matching { */
  1077.  
  1078.         if ( !trc_find_event_str( ID, "}" ) )
  1079.             return( TRC_FALSE );
  1080.     }
  1081.  
  1082.     return( TRC_TRUE );
  1083. }
  1084.  
  1085.  
  1086. void
  1087. trc_dump_old_sddf_headers()
  1088. {
  1089.     int i;
  1090.  
  1091.     printf( "\n" );
  1092.     printf( "XPVM Trace Format Descriptors for PVM 3.3 - SDDF:\n" );
  1093.     printf( "=================================================\n" );
  1094.  
  1095.     for ( i=TRC_OLD_TEV_FIRST ; i < TRC_OLD_TRACE_MAX ; i++ )
  1096.     {
  1097.         if ( strcmp( TRC_OLD_TRACE_DESCRIPTORS[i], "" ) )
  1098.         {
  1099.             printf( "\n#%d: %s\n", i + 1,
  1100.                 TRC_OLD_TRACE_DESCRIPTORS[i] );
  1101.         }
  1102.     }
  1103.  
  1104.     exit( 0 );
  1105. }
  1106.  
  1107.  
  1108. void
  1109. trc_reset_old_descriptors()
  1110. {
  1111.     int i;
  1112.  
  1113.     for ( i=TRC_OLD_TEV_FIRST ; i < TRC_OLD_TRACE_MAX ; i++ )
  1114.         TRC_OLD_TEV_TRACE[i] = 0;
  1115. }
  1116.  
  1117.